package com.droidnova.android.games.vortex;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

import android.util.Log;

public class triangles1 {
	// Our vertex buffer.
	FloatBuffer _pvertexBuffer;
	//our Color buffer
	FloatBuffer _pcolorBuffer;
	//noVertices
	int _noVertices;
	float _pcolors[] , _pvertices[];
	




	public triangles1(float _pcolors1[] ,float _pvertices1[], int _noVertices1)
	{
		//_pcolors = _pcolors1;
		//_pvertices = _pvertices1;
		//_noVertices = _noVertices1;
		set_noVertices(_noVertices1);
		set_pvertices(_pvertices1);
		set_pcolors(_pcolors1);
		
		//DISPLAY______________________________________________
		/*for (Float in : _pcolors)
	     {
	         Log.v("color", "color -> " + in);
	     }
	     
	     for (Float op1 : _pvertices)
	     {
	         Log.v("vertex", "vertex -> " + op1);
	     }
	     Log.v("noVertices", "noVertices -> " + _noVertices);*/
	     //__________________________________________________
		
		
		
		
	}
	



	public float[] get_pcolors() {
		return _pcolors;
	}


	public void set_pcolors(float[] _pcolors4) {
		_pcolors = _pcolors4;
	}
	public float[] get_pvertices() {
		return _pvertices;
	}

	public void set_pvertices(float[] _pvertices4) {
		_pvertices = _pvertices4;
	}


	public int get_noVertices() {
		return _noVertices;
	}

	public void set_noVertices(int _noVertices4) {
		_noVertices = _noVertices4;
	}



	
	public void draw(GL10 gl) {
		ByteBuffer vbb,cbb;
		//vbb.clear();
		vbb= ByteBuffer.allocateDirect(get_pvertices().length * 4);
		vbb.order(ByteOrder.nativeOrder());
		_pvertexBuffer = vbb.asFloatBuffer();
		_pvertexBuffer.clear();
		_pvertexBuffer.put(get_pvertices());
		_pvertexBuffer.position(0);
		
		
		//color buffer
		//vbb.clear();
		cbb = ByteBuffer.allocateDirect(get_pcolors().length * 4);
		cbb.order(ByteOrder.nativeOrder());
		_pcolorBuffer = cbb.asFloatBuffer();
		_pcolorBuffer.clear();
		_pcolorBuffer.put(get_pcolors());
		_pcolorBuffer.position(0);
		
		
		
		
		/*_pvertexBuffer.clear();
		_pvertexBuffer.put(get_pvertices());
		_pvertexBuffer.position(0);
		
		
		
		_pcolorBuffer.clear();
		_pcolorBuffer.put(get_pcolors());
		_pcolorBuffer.position(0);*/
		
		
		

		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
	
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, _pvertexBuffer);
		gl.glColorPointer(4, GL10.GL_FLOAT, 0, _pcolorBuffer);
		//set the point size
		gl.glEnable(GL10.GL_POINT_SMOOTH);
        gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST);
		gl.glPointSize(5);
        
		// finally draw the vertices
		// gl.glTranslatef(-0.5f, -0.3f, -0.5f);
		//gl.glRotatef(45.0f, 1.0f,0.0f,1.0f);
		gl.glDrawArrays(GL10.GL_POINTS, 0,get_noVertices());
	
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
	}
}
